package com.example.blog_system_ssm.tools;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class BCryptTest {
    public static void main(String[] args) {
        String password="admin";
        System.out.println("加密前的密码为："+password);

        // 密码加密
        BCryptPasswordEncoder bCryptPasswordEncoder=new BCryptPasswordEncoder();
        String newPassword=bCryptPasswordEncoder.encode(password);

        System.out.println("加密后的密码为:"+newPassword);

        // 密码校验
        boolean same_password_result=bCryptPasswordEncoder.matches(password,newPassword);

        System.out.println("新旧密码校验结果:"+same_password_result);

        boolean other_password_result=bCryptPasswordEncoder.matches("adasdasd",newPassword);

        System.out.println("加密密码和错误密码校验结果："+other_password_result);


    }


}
